<?php use_helper('Date')?>
<?php use_javascript('/js/e-dsl/datepicker.js') ?>
<?php use_stylesheet('/css/e-dsl/datepicker.css') ?>
<?php $objDef = new objectDef($d->getClassname());?>
<?php include_partial('dossiers/jsSelectTypeDemande', array('form' => $form, 'objDef' => $objDef)) ?>

<script type="text/javascript">

</script>

<?php if (isset($form)):?>
<?php include_partial('dossiers/demandeHeader', array('demande' => $d));?>	
	<div id="hidenFieldsHeader" style="display: none">
			<?php echo $form['id']->render() ?>
			<?php //echo $form['typePere']->render() ?>
			<?php echo $form['type_id']->render() ?>
			<?php echo $form['categorie_id']->render() ?>
			<?php //echo $objDef->renderAttributeWidget($form, 'type_id'); ?>
			<?php //echo $objDef->renderAttributeWidget($form, 'categorie_id'); ?>
	</div>
	<?php if($d->getClassname()=='demandes'): ?>
	<fieldset><legend>D&eacute;lai de la demande</legend>
		<?php include_partial('dossiers/demandeDateFields', array('form' => $form, 'objDef' => $objDef)) ?>
	</fieldset>
	<?php endif;?>			
	<?php  if ($form->isCSRFProtected()) : ?> 
	  <?php echo $form['_csrf_token']; ?> 
	<?php endif; ?>
                           
<?php endif;?>

<script type="text/javascript">
function customValHead(validators){
	 className = "<?php echo $d->getClassname() ?>";
	 if (className == 'demandes'){
		 if (!verifdt(document.getElementById("demandes1_dateRealSouhaitee").value)){
						validators.push(tmt.validator.fieldValidatorFactory(document.getElementById("demandes1_dateRealSouhaitee")));	
		 }else{
			var xDateSouhaitee = document.getElementById('demandes1_dateRealSouhaitee');
			dDateSouhaitee = getFieldDate(xDateSouhaitee.value);
			var currentDate=new Date();
			if (currentDate>=dDateSouhaitee){
				x = validators.length;
				validators.push(tmt.validator.fieldValidatorFactory(document.getElementById("demandes1_dateRealSouhaitee")));
				validators[x].message = "La date souhait\351e est anterieur a la date de la demande.";
			}	 
		 }
		 if (document.getElementById('demandes1_urgent').value == 'true'){
			 if(ltrim(document.getElementById("demandes1_justifurgence").value)==""){
						validators.push(tmt.validator.fieldValidatorFactory(document.getElementById("demandes1_justifurgence")));
			 }	
		 }
	 }
}
</script>

